/*
 * Copyright 2014 Henrik Baerbak Christensen, Aarhus University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cs.rsa.ts14.india.statemachine;

import cs.rsa.ts14.framework.*;

/**
 * Define a ConcreteState for the LineSequenceState
 * 
 * @author Henrik Baerbak Christensen, Aarhus University
 * 
 */

public class WeekState implements LineSequenceState {

	private final String currentStateName = "week";
	private String errorLine = "OK";

	@Override
	public String lastError() {
		return errorLine;
	}

	@Override
	public LineSequenceState transitionOn(LineType lineType) {
		LineSequenceState state = null;
		switch (lineType) {
		case COMMENT_LINE:
			state = new CommentState(this);
			break;
		case EMPTY_LINE:
			state = new EmptyState(this);
			break;
		case ASSIGNMENT_LINE:
			state = new IllegalState("Illegal to have assignment after "
					+ currentStateName + " line.");
			break;
		case WEEK_SPECIFICATION:
			state = new IllegalState("Illegal to have week after "
					+ currentStateName + " line.");
			break;
		case WEEKDAY_SPECIFICATION:
			state = new WeekDayState();
			break;
		case WORK_SPECIFICATION:
			state = new IllegalState("Illegal to have work after initial line.");
			break;
		case INVALID_LINE:
			state = this;
			errorLine = "Invalid line";
			break;
		case INVALID_SEQUENCE:
			state = new IllegalState("Invalid sequence.");
			break;
		default:
			break;
		}
		return state;
	}

}
